<template>
  <div class="quick-access">
    <el-icon :size="24" class="home-icon">
      <HomeFilled />
    </el-icon>
    <span class="title-text">Global Cloud Cost Management</span>

    <!-- 快速操作按钮 -->
    <div class="quick-actions">
      <el-tooltip
        v-for="(btn, index) in buttons"
        :key="index"
        placement="bottom"
        :content="btn.tooltip"
      >
        <el-button class="action-btn" circle plain @click="clickedBtn(btn.type)">
          <el-icon>
            <component :is="btn.icon" />
          </el-icon>
        </el-button>
      </el-tooltip>
    </div>
  </div>
</template>

<script setup lang="ts">
import { defineProps } from 'vue'
import { useEvents } from '../events/useEventBus'
import {
  HomeFilled,
  DocumentCopy,
  DocumentAdd,
  RefreshLeft,
  RefreshRight,
} from '@element-plus/icons-vue'

function clickedBtn(type: string) {
  console.log(type)
  useEvents().emitGlobal(type, {
    'test1': type,
    'test2': 'fasjdfafdj',
   });
}

// 按钮数据
const buttons = [
  { icon: DocumentCopy, tooltip: '复制', type: 'COPY' },
  { icon: DocumentAdd, tooltip: '粘贴', type: 'PAST' },
  { icon: RefreshLeft, tooltip: '撤销', type: 'CTRL+Z' },
  { icon: RefreshRight, tooltip: '恢复', type: 'COPY+Y' },
]
</script>

<style scoped>
.quick-access {
  display: flex;
  align-items: center;
  margin-right: 40px;
}

.home-icon {
  color: #409eff;
  margin-right: 8px;
}

.title-text {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  margin-right: 16px;
  white-space: nowrap;
}

.quick-actions {
  display: flex;
  gap: 6px;
}

.action-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f7fa;
  border-color: #dcdfe6;
  transition: all 0.2s;
}

.action-btn:hover {
  background: #ecf5ff;
  border-color: #409eff;
  transform: translateY(-1px);
}

.action-btn .el-icon {
  font-size: 14px;
}
</style>
